package com.itcast.rabbitmq.spring;


import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @ClassName SpringMain
 * @Description TODO
 * @Author Trigger Wu
 * @Date 2018/9/2815:18
 * @Version 1.0
 **/

public class SpringMain {
    public static void main(final String... args) throws Exception {
        AbstractApplicationContext ctx = new ClassPathXmlApplicationContext(
                "classpath:spring/rabbitmq-context.xml");
        //RabbitMQ模板
        RabbitTemplate template = ctx.getBean(RabbitTemplate.class);
        //发送消息

        template.convertAndSend("Hello, world!");
        Thread.sleep(1000);// 休眠1秒
        ctx.close();//容器销毁
    }
}
